package ee.az.tetris.worker;

import ee.az.tetris.Glass;
import ee.az.tetris.event.Event;

/**
 * @author Artur Zinatullin (artur.zinatullin@gmail.com) 2010
 */
public abstract class Worker {

	private final Glass glass;

	public Worker(Glass glass) {
		this.glass = glass;
	}

	public abstract void work(Event event);
	
	protected boolean isAvaliable(int col, int row, Glass glass) {
		if (row < 0 || row >= glass.getRowCount()) {
			return false;
		} else if (col < 0 || col >= glass.getColumnCount()) {
			return false;
		} else {
			return Glass.EMPTY.equals(glass.getValue(col, row)) || Glass.FLOATING.equals(glass.getValue(col, row));
		}
	}
	
	public Glass getGlass() {
		return glass;
	}
}
